/**
 * 
 */
package com.gr.staffpm.widget.jqgrid.model;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.gr.staffpm.datatypes.IDatatype;

/**
 * @author Graham Rhodes
 *
 */
public abstract class CellLink<T extends IDatatype> extends Panel {

    private static final long serialVersionUID = 1L;

    public CellLink(String id, final IModel<T> model) {
        super(id);

        AjaxLink<Void> link = new AjaxLink<Void>("link") {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                CellLink.this.onClick(target, model);
            }
        };

        add(link);
        link.add(new Label("text", model.getObject().getDisplayValue()).setRenderBodyOnly(true));

    }

    public abstract void onClick(AjaxRequestTarget target, IModel<T> model);

}
